<?
//inculde即可以使用data数据。本页所有的data数据，倾在controller都处理好
include_once("../../../common/modules/checkA.php");
include_once("../../../../config.php");

$now_member=select_one_line_all_items($table_Prefix."member","nid = '".$_REQUEST ['nid']."'");

?>





<?php
//接收需要修改的数据的id
$new_detail_nid          = addslashes($_REQUEST['nid']);


//传递过来的页面信息。返回的时候，会根据这些信息返回原来的页面
$nowpageid = addslashes($_REQUEST['nowpageid']);
$sys_part  = addslashes($_REQUEST['sys_part']);


if($_REQUEST['ai_leader_apply']=="通过")
{
    $_REQUEST['ai_leader']="是";
}
else
{
    $_REQUEST['ai_leader']="否";
}


$_REQUEST['ai_authur']      = $_SESSION['username'];
$_REQUEST['ai_ip']          = $_SERVER["REMOTE_ADDR"];
$_REQUEST['ai_tag']=str_replace("；",";",$_REQUEST['ai_tag']);



$sql=update_date($table_prefix."member",$_REQUEST,"nid",$new_detail_nid);
$query = do_query($sql) or die ("error:".mysqli_error());






//开始修改团队标签
$table=$table_prefix."member_group";

//首先清除旧标签
$del_member_tag_sql = " DELETE FROM $table WHERE member_nid = $new_detail_nid";
$query=do_query($del_member_tag_sql) or die ('删除数据失败'.$del_member_tag_sql);


//组成新数组
//print_r2($_REQUEST['group']);
$i=0;
foreach ($_REQUEST['group'] as $k=>$v)
{
    $_group[$i]['ai_member_nid']=$new_detail_nid;
    $_group[$i]['ai_group_nid'] =$v;
    $_group[$i]['ai_status']    ="正常";
    $_group[$i]['ai_add_time']  =date("Y-m-d H:i:s");
    $i++;
}


$p['table']=$table;
$p['items']=array("member_nid","group_nid","status","add_time");
$p['values']=$_group;

$_creat_mamber_group_tag=insert_datas($p);
$query=do_query($_creat_mamber_group_tag) or die ('插入标签失败'."error:".mysqli_error().$_creat_mamber_group_tag);


?>



<script type="text/javascript">
    alert("输入信息已保存，点击确认返回继续操作.");
    document.location.href = "../view/detail-edit.php?nowpageid=<? echo $nowpageid ?>&sortby=<? echo $sortby?>&nid=<? echo $new_detail_nid ?>&sys_part=<? echo $sys_part ?>"
</script>

